<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Model;

use Hyperf\DbConnection\Model\Model;

class CustomerRoles extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'customer_roles';

    protected array $fillable = [
        'id', 'role_name', 'identify', 'description', 'data_range', 'creator_id', 'created_at', 'updated_at', 'deleted_at',
    ];

    protected string $primaryKey = 'id';

    protected ?string $dateFormat = 'U';

    /**
     * @return mixed
     */
    public function permissions()
    {
        return $this->belongsToMany(CustomerPermissions::class, 'customer_role_has_permissions', 'role_id', 'permission_id');
    }
}
